]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ibusManager: Avoid reusing a renewed cancellable across async calls
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Thu, 23 Jul 2026 10:02:04 +0000 (12:02 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sun, 2 Aug 2026 16:50:53 +0000 (18:50 +0200)
When the shared cancellable gets renewed, in-flight async requests can end up
using the wrong instance.
Pass a stable cancellable per operation so each request stays bound to the
cancellable it started with.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/4296>
(cherry picked from commit ecbfbcb78e25b342687623c52e17c413a4263315)

js/misc/ibusManager.js

index d9995b81a7ab6feb6ae0b0ca461a2ff6792a30bd..0e76a13fccde04c11ecf5de9d8aee5d921fb0d7f 100644 (file)
@@ -160,14 +160,14 @@ class IBusManager extends Signals.EventEmitter {
 
     _onConnected() {
         this._cancellable = new Gio.Cancellable();
-        this._initEngines();
-        this._initPanelService();
+        this._initEngines(this._cancellable);
+        this._initPanelService(this._cancellable);
     }
 
-    async _initEngines() {
+    async _initEngines(cancellable) {
         try {
             const enginesList =
-                await this._ibus.list_engines_async(-1, this._cancellable);
+                await this._ibus.list_engines_async(-1, cancellable);
             for (let i = 0; i < enginesList.length; ++i) {
                 const name = enginesList[i].get_name();
                 this._engines.set(name, enginesList[i]);
@@ -179,10 +179,10 @@ class IBusManager extends Signals.EventEmitter {
         }
     }
 
-    async _initPanelService() {
+    async _initPanelService(cancellable) {
         try {
             await this._ibus.request_name_async(IBus.SERVICE_PANEL,
-                IBus.BusNameFlag.REPLACE_EXISTING, -1, this._cancellable);
+                IBus.BusNameFlag.REPLACE_EXISTING, -1, cancellable);
         } catch (e) {
             if (logErrorUnlessCancelled(e))
                 this._clear();
@@ -220,7 +220,7 @@ class IBusManager extends Signals.EventEmitter {
         try {
             // If an engine is already active we need to get its properties
             const engine =
-                await this._ibus.get_global_engine_async(-1, this._cancellable);
+                await this._ibus.get_global_engine_async(-1, cancellable);
             this._engineChanged(this._ibus, engine.get_name());
         } catch {
         }
@@ -279,10 +279,11 @@ class IBusManager extends Signals.EventEmitter {
         if (!this._ready)
             return;
 
+        const cancellable = this._cancellable;
         try {
             await this._ibus.set_global_engine_async(id,
                 this._MAX_INPUT_SOURCE_ACTIVATION_TIME,
-                this._cancellable);
+                cancellable);
         } catch (e) {
             if (!logErrorUnlessCancelled(e))
                 return;
@@ -290,7 +291,7 @@ class IBusManager extends Signals.EventEmitter {
             try {
                 await this._ibus.set_global_engine_async(FALLBACK_ENGINE_ID,
                     this._MAX_INPUT_SOURCE_ACTIVATION_TIME,
-                    this._cancellable);
+                    cancellable);
             } catch (e2) {
                 logErrorUnlessCancelled(e2);
             }